//
//  WYWSqliteToolTest.m
//  SQlite
//
//  Created by Mr.Run on 2017/11/13.
//  Copyright © 2017年 Mr.Run. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "WYWSqliteTool.h"
#import "WYWSqliteModelTool.h"
#import "WYWStu.h"

@interface WYWSqliteToolTest : XCTestCase

@end

@implementation WYWSqliteToolTest

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    
//    NSString *sql = @"create table if not exists t_stu(id integer primary key autoincrement, name text not null, age integer, score real)";
//    BOOL result = [WYWSqliteTool deal:sql uid:nil];
    Class cls = NSClassFromString(@"WYWStu");
//    BOOL result = [WYWSqliteModelTool createTable:cls uid:nil];
//    BOOL result = [WYWSqliteModelTool isTableRequiredUpdated:cls uid:nil];
    
    BOOL result = [WYWSqliteModelTool updateTable:cls uid:nil];
    
    XCTAssertEqual(result, YES);
    
}

- (void)testQuery{
    
    NSString *sql = @"select * from t_stu";
    
    NSMutableArray *arr = [WYWSqliteTool querySql:sql uid:nil];
    NSLog(@"%s~~~%d~~~%@",__func__,__LINE__,arr);
}

- (void)testQueryAllModels{
    NSArray *arr = [WYWSqliteModelTool queryModels:[WYWStu class] columnName:@"age" relation:ColumnNameToValueRelationTypeEqual value:@"182" uid:nil];
    NSLog(@"%s~~~%d~~~%@",__func__,__LINE__,arr);
}

- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

@end
